mooni2p = require("mooni2p")

local session_name = "testclient"
local target = arg[1]

if target == nil then
	print(string.format("missing target. usage: lua5.3 %s target.i2p", arg[0]))
else
	-- create client SAM session
	local session_sock = assert(mooni2p.create_session(session_name))
	-- connect to remote I2P destination
	local sock = assert(mooni2p.stream_connect(session_name, target))

	sock:send("PING\n")
	local data = sock:receive("*l")
	print(data)
	sock:send("STOP\n")

	sock:close()

	-- shutdown SAM session
	session_sock:close()
end
